package com.hunliji.monitor.service.impl;

import com.hunliji.monitor.dao.mapper.mt.ChatGroupMemberMapper;
import com.hunliji.monitor.dao.model.dataobject.ChatGroupMemberDO;
import com.hunliji.monitor.dao.model.param.QueryChatGroupMemberDataParam;
import com.hunliji.monitor.service.api.ChatGroupMemberService;
import com.hunliji.monitor.service.api.model.bo.ChatGroupMemberBO;
import com.hunliji.monitor.service.api.model.param.QueryChatGroupMemberParam;
import com.hunliji.monitor.share.component.ComponentLocator;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 群组成员
 * @author wuchen
 */
@Service
public class ChatGroupMemberServiceImpl implements ChatGroupMemberService {
    @Resource
    private ChatGroupMemberMapper chatGroupMemberMapper;
    @Override
    public void save(ChatGroupMemberBO chatGroupMemberBO) {
        ChatGroupMemberDO chatGroupMemberDO = ComponentLocator.getConverter().convert(chatGroupMemberBO,ChatGroupMemberDO.class);
        chatGroupMemberMapper.insert(chatGroupMemberDO);
    }

    @Override
    public void update(ChatGroupMemberBO chatGroupMemberBO) {
        ChatGroupMemberDO chatGroupMemberDO = ComponentLocator.getConverter().convert(chatGroupMemberBO,ChatGroupMemberDO.class);
        chatGroupMemberMapper.updateById(chatGroupMemberDO);
    }

    @Override
    public List<ChatGroupMemberBO> query(QueryChatGroupMemberParam queryChatGroupMemberParam) {
        QueryChatGroupMemberDataParam queryChatGroupMemberDataParam = ComponentLocator.getConverter().convert(queryChatGroupMemberParam,QueryChatGroupMemberDataParam.class);
        List<ChatGroupMemberDO> chatGroupMemberDOList = chatGroupMemberMapper.query(queryChatGroupMemberDataParam);
        List<ChatGroupMemberBO> chatGroupMemberBOList = ComponentLocator.getConverter().convertList(chatGroupMemberDOList,ChatGroupMemberBO.class);
        return chatGroupMemberBOList;
    }
}
